<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>运动信息修改</title>
    <link rel="stylesheet" type="text/css" href="../css/style.css"/>
    <script type="text/javascript" src="../js/jquery-1.8.3.min.js"></script>
    <script type="text/javascript" src="../laydate/laydate.js"></script>
    <script src="../js/city-picker.data.js"></script>
    <script src="../js/city-picker.js"></script>
    <script src="../js/publicJS.js"></script>
    <style>

    </style>
</head>

<body style="background:#328f46">
<div class="headiv">
    <div class="logotag">
        <a class="logo"><img src="../img/logo.png" width="440" height="65"></a>
        <b class="line"></b>
    </div>
    <a class="username">欢迎登录：<i id="name"></i></a>
    <span class="btnbox">
    	<a class="update" href="/updatePerson" title="修改"></a><a class="exit" href="/logout" title="退出"></a>
    </span>
    <div class="clear" style="height:20px; background:#328f46"></div>
</div>

<div class="messagebox">
    <div class="messageleft">
        <ul class="Fstage">
            <shiro:hasRole name="normalUser">
                <li><a href="#"><em class="e3"></em>健康信息管理
                    <div class="clear"></div>
                </a>
                    <ul class="Tstage">
                        <li><a href="/healthInfoAdd">健康信息录入</a></li>
                        <li><a href="/healthInfoSelect">健康指数查询</a></li>
                    </ul>
                </li>
                <li><a href="#"><em class="e3"></em>运动信息管理
                    <div class="clear"></div>
                </a>
                    <ul class="Tstage">
                        <li><a href="/sportIndex">运动信息录入</a></li>
                        <li><a href="/sportIndexSelect">运动信息查询</a></li>
                    </ul>
                </li>
                <li><a href="#"><em class="e3"></em>心理测试
                    <div class="clear"></div>
                </a>
                    <ul class="Tstage">
                        <li><a href="/testPage">开始测试</a></li>
                        <li><a href="/testrecord">测试记录</a></li>
                    </ul>
                </li>
                <li><a href="#"><em class="e3"></em>健康新闻
                    <div class="clear"></div>
                </a>
                    <ul class="Tstage">
                        <li><a href="/healthnewsPage">健康新闻</a></li>
                    </ul>
                </li>
            </shiro:hasRole>

            <shiro:hasRole name="admin">
                <li><a href="#"><em class="e3"></em>用户管理
                    <div class="clear"></div>
                </a>
                    <ul class="Tstage">
                        <li><a href="/userManagement">用户管理</a></li>
                    </ul>
                </li>
                <li><a href="#"><em class="e3"></em>发布新闻
                    <div class="clear"></div>
                </a>
                    <ul class="Tstage">
                        <li><a href="/releaseNewsPage">发布新闻</a></li>
                    </ul>
                </li>
            </shiro:hasRole>
        </ul>
    </div>
    <!--****************以上不能动，页面固定的东西************************-->
    <div class=" messageright formpage">
        <h2>修改个人信息</h2>
        <br>
        <br>
        nickname :<input type="text" id="nickname" class="textput"><br><br>
        signature:<input type="text" id="signature" class="textput"><br><br>
        sex      :<input type="text" id="sex" class="textput"><br><br>
        age      :<input type="text" id="age" class="textput"><br><br>
        phoneNumber:<input type="text" id="phoneNumber" class="textput"><br><br>
        area     :<input type="text" id="area" class="textput"><br><br>
        constellationId:<input type="text" id="constellationId" class="textput"><br><br>
        <%--birthday :<input type="text" id="birthday" class="textput"><br><br>--%>
        email    :<input type="text" id="email" class="textput"><br><br>
        <%--erTime" class="textput">--%>
        <br>
        <br>
        <input type="button" id="save" value="保存" class="greenbtn">
    </div>
</div>
</body>
<script>
    $.ajax({
        url:"/selectUser",
        type:"post",
        success:function (result) {
            console.log(result)
            for (var i in result){
                var re = result[i];
                var nickname=re.nickname;
                var signature=re.signature;
                var sex=re.sex;
                var age=re.age;
                var phoneNumber=re.phoneNumber;
                var area = re.area;
                var constellationId=re.constellationId;
//                var birthday=re.birthday;
                var email=re.email;
//                var registerTime=re.registerTime;
                $("#nickname").val(nickname);
                $("#signature").val(signature);
                $("#sex").val(sex);
                $("#age").val(age);
                $("#phoneNumber").val(phoneNumber);
                $("#area").val(area);
                $("#constellationId").val(constellationId);
//                $("#birthday").val(birthday);
                $("#email").val(email);
//                $("#registerTime").val(registerTime);
            }
        }
    });

    //点击保存修改数据
    $("#save").click(function () {
        $.ajax({
            url:"/updatePerson1",
            type:"post",
            data:{
                nickname:$("#nickname").val(),
                signature:$("#signature").val(),
                sex:$("#sex").val(),
                age:$("#age").val(),
                phoneNumber:$("#phoneNumber").val(),
                area:$("#area").val(),
                constellationId:$("#constellationId").val(),
                email:$("#email").val(),
            },
            success:function (result) {
                console.log(result)
                alert("修改成功")
                if (result){
                    window.location.href="/sportIndexSelect";
                }
            }
        });

    });
</script>

</html>